<?php

class FundLvRewardAction extends SzAbstractAction
{
    Protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_ARRAY,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * @param $userId
     * @param $fundId
     * @param $fundRewardIds
     * @param $reqTime
     * @return SzResponse
     * @throws SzException
     */
    public function execute($userId,$fundId,$fundRewardIds,$reqTime)
    {
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_FUND_FUNC)) {
            return $this->buildResponse(false);
        }
        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);

        foreach ($fundRewardIds as $fundRewardId) {
            FundService::get()->fundReward($userId,$fundId,$fundRewardId,$reqTime);
        }
        /**
         * @var FundInfoVoList $fundInfoList
         * @var FundInfoVo $fundInfo
         */
        $fundInfoList = SzPersister::get()->getVoList($userId, GameConst::ORM_NAME_FUND_INFO);
        $fundInfo = $fundInfoList->getElement($fundId,false);

       $return = array(
            'code' => 0,
            'fundInfo' => $fundInfo->toArray()
        );

        return $this->buildResponse(
            $return
        );
    }
}